<!DOCTYPE HTML>
<html>
	<head>
		<script id="allmobilize" charset="utf-8" src="style/js/allmobilize.min.js"></script>
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="alternate" media="handheld" />
		<!-- end 云适配 -->
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>登录</title>
		<meta property="qc:admins" content="23635710066417756375" />

		<meta name="baidu-site-verification" content="QIQ6KC1oZ6" />

		<!-- <div class="web_root"  style="display:none">h</div> -->
		<script type="text/javascript">
			var ctx = "h";
			console.log(1);
		</script>
		<link rel="Shortcut Icon" href="h/images/favicon.ico">
		<link rel="stylesheet" type="text/css" href="style/css/style.css" />

		<script src="style/js/jquery.1.10.1.min.js" type="text/javascript"></script>

		<script type="text/javascript" src="style/js/jquery.lib.min.js"></script>
		<script type="text/javascript" src="style/js/core.min.js"></script>
		<script type="text/javascript" src="style/js/neturl.js"></script>
	</head>

	<body id="login_bg">
		<div class="login_wrapper">
			<div class="login_header">
				<a href="h/"><img src="style/images/logo_white.png" width="285" height="80" alt="东莞大学生兼职企业端" /></a>
				<div id="cloud_s"><img src="style/images/cloud_s.png" width="81" height="52" alt="cloud" /></div>
				<div id="cloud_m"><img src="style/images/cloud_m.png" width="136" height="95" alt="cloud" /></div>
			</div>

			<input type="hidden" id="resubmitToken" value="" />
			<div class="login_box">
				<form id="loginForm" action="index.html">
					<input type="text" id="username" name="username" value="" tabindex="1" placeholder="请输入用户名" style="width: 296px;" />
					<input type="password" id="password" name="password" tabindex="2" placeholder="请输入密码" />
					<span class="error" style="display:none;" id="beError"></span>
					<label class="fl" for="remember"><input type="checkbox" id="remember" value="" checked="checked" name="autoLogin" />
						记住我</label>
					<a href="reset.html" class="fr" target="_blank">忘记密码？</a>

					<!--<input type="submit" id="submitLogin" value="登 &nbsp; &nbsp; 录" />-->
					<a style="color:#fff;" class="submitLogin" onclick="to_Login()"/>登 &nbsp; &nbsp; 录</a>


					<input type="hidden" id="callback" name="callback" value="" />
					<input type="hidden" id="authType" name="authType" value="" />
					<input type="hidden" id="signature" name="signature" value="" />
					<input type="hidden" id="timestamp" name="timestamp" value="" />
				</form>
				<div class="login_right">
					<div>还没有帐号？</div>
					<a href="register.html" class="registor_now">立即注册</a>
					<div class="login_others">使用以下帐号直接登录:</div>
					<a href="h/ologin/auth/sina.html" target="_blank" class="icon_wb" title="使用新浪微博帐号登录"></a>
					<a href="h/ologin/auth/qq.html" class="icon_qq" target="_blank" title="使用腾讯QQ帐号登录"></a>
				</div>
			</div>
			<div class="login_box_btm"></div>
		</div>

		<script type="text/javascript">
			$(function() {
				//验证表单
				$("#loginForm").validate({
					/* onkeyup: false,
	    	focusCleanup:true, */
					rules: {
						username: {
							required: true
						},
						password: {
							required: true
						}
					},
					messages: {
						username: {
							required: "请输入用户名"
						},
						password: {
							required: "请输入密码"
						}
					},
					submitHandler: function(form) {
						if ($('#remember').prop("checked")) {
							$('#remember').val(1);
						} else {
							$('#remember').val(null);
						}
						var username = $('#username').val();
						var password = $('#password').val();
						var remember = $('#remember').val();
					}
				});
			})
			
			function to_Login(){
				var username = $('#username').val();
				var password = $('#password').val();
				if(username == ""){
					alert("请输入用户名");
					return;
				}
				if(password == ""){
					alert("请输入密码");
					return;
				}
				$.ajax({ //传数据的方式
					url: ip_address+"/companys/login",
					type: "post",
					data:{
						UserName:username,
						Password:password
					},
					success: function(result, request) { //传数据成功之后的操作   result是servlet传过来的数据  这个函数对result进行处理，让它显示在 输入框中
						console.log('返回了' + JSON.stringify(result))
						var status = result.status;
						if(status == 0){
							var data = result.data;
							var cname = data.cname;
							var email = data.email;
							var uname = data.userName;
							var id = data.id;
							setCookie('company_id',id)
							setCookie('cname',cname)
							setCookie('cemail',email)
							setCookie('uname',uname)
							window.location.href = "index.html";
						}else{
							var msg = result.msg;
							alert(msg);
						}
					},
					error: function(Error) {
						console.log(Error);
					},
					complete: function(xhr, data) {
						console.log("complete");
					}
				});
			}
			
			//存cookie
			function setCookie(name, value) {
				var Days = 30;
				var exp = new Date();
				exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
				document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
			}
		</script>
	</body>
</html>
